//
//  ListVCCellTwo.m
//  EducationAdminClient
//
//  Created by kwsdzjx on 16/4/1.
//  Copyright © 2016年 周佳兴. All rights reserved.
//

#import "ListVCCellTwo.h"
#import "Masonry.h"
#import "UIColor+CL.h"
#import "EducationAdminClient_URL.h"
#define KWIDTH ([UIScreen mainScreen].bounds.size.width) //屏幕宽度
@implementation ListVCCellTwo

-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
    //    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    if (self) {
        UIView *superView = [self createUI];
        superView.backgroundColor = [UIColor whiteColor];
        superView.layer.cornerRadius = 8;
        self.backgroundColor = [UIColor clearColor];
        
        [self.contentView addSubview:superView];
        //#ifdef Main
        if([getUIStyle() isEqualToString:STYLE0]){
            [superView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.contentView.mas_left);
                make.top.equalTo(self.contentView.mas_top).offset(26/2);
                make.right.equalTo(self.contentView.mas_right);
                make.bottom.equalTo(self.contentView.mas_bottom);
            }];
            
        }else{
            //#elif Student
            
            [superView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.contentView.mas_left);
                make.top.equalTo(self.contentView.mas_top).offset(20/2);
                make.right.equalTo(self.contentView.mas_right);
                make.bottom.equalTo(self.contentView.mas_bottom);
            }];
        }
        //#elif Teacher
        //        //    rootview
        //        NSLog(@"老师端程序");
        //#else
        //
        //        NSLog(@"都不是");
        //#endif
        
    }
    return self;
}

-(UIView *)createUI{
    self.baseView = [[UIView alloc]init];
    self.BtnView  = [[UIView alloc]init]; // 下方可变按钮 view 实例化
    
    [self.baseView addSubview:self.BtnView];
    [self.BtnView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.baseView.mas_left);
        make.bottom.equalTo(self.baseView.mas_bottom);
        make.width.equalTo(self.baseView.mas_width);
        make.height.equalTo(@(76/2));
    }];
    //    UIImageView *titleImgView = [[UIImageView alloc]init];
    //    [self.baseView addSubview:titleImgView];
    
    self.titleLeftImg = [[UIImageView alloc]init];
    [self.baseView addSubview:self.titleLeftImg];
    
    self.titleLabel = [[UILabel alloc]init];
    [self.baseView addSubview:self.titleLabel];
    
    self.subTitleLabel = [[UILabel alloc]init];
    [self.baseView addSubview:self.subTitleLabel];
    
    self.titleRightImg = [[UIImageView alloc]init];
    [self.baseView addSubview:self.titleRightImg];
    
    self.Label1 = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label1];
    
    self.Label2 = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label2];
    
    self.Label3 = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label3];
    
    self.Label4 = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label4];
    
    self.Label5 = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label5];
    
    self.Label1R = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label1R];
    
    self.Label2R = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label2R];
    
    self.Label3R = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label3R];
    
    self.Label4R = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label4R];
    
    self.Label5R = [[UILabel alloc]init];
    [self.baseView addSubview:self.Label5R];
    
    [self.Label1 setContentHuggingPriority:UILayoutPriorityRequired
                                   forAxis:UILayoutConstraintAxisHorizontal];//宽度够的时候优先级宽度根据label内容
    [self.Label2 setContentHuggingPriority:UILayoutPriorityRequired
                                   forAxis:UILayoutConstraintAxisHorizontal];//宽度够的时候优先级宽度根据label内容
    [self.Label3 setContentHuggingPriority:UILayoutPriorityRequired
                                   forAxis:UILayoutConstraintAxisHorizontal];//宽度够的时候优先级宽度根据label内容
    [self.Label4 setContentHuggingPriority:UILayoutPriorityRequired
                                   forAxis:UILayoutConstraintAxisHorizontal];//宽度够的时候优先级宽度根据label内容
    [self.Label1 setContentCompressionResistancePriority:UILayoutPriorityRequired
                                                 forAxis:UILayoutConstraintAxisHorizontal];
    //    [self.Label1 setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    
    
    [self.Label2 setContentCompressionResistancePriority:UILayoutPriorityRequired
                                                 forAxis:UILayoutConstraintAxisHorizontal];
    //    [self.Label2 setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    
    
    [self.Label3 setContentCompressionResistancePriority:UILayoutPriorityRequired
                                                 forAxis:UILayoutConstraintAxisHorizontal];
    //    [self.Label3 setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    
    
    [self.Label4 setContentCompressionResistancePriority:UILayoutPriorityRequired
                                                 forAxis:UILayoutConstraintAxisHorizontal];
    //    [self.Label4 setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    
    _imgLine = [[UIImageView alloc]init];
    //    [self.Label2 sizeToFit];
    [self.baseView addSubview:_imgLine];
    
    
    self.mormalBtn = [[NormalButton alloc]init];
    [self.baseView addSubview:self.mormalBtn];
    
    //    [titleImgView mas_makeConstraints:^(MASConstraintMaker *make) {
    //        make.left.equalTo(self.baseView.mas_left);
    //        make.top.equalTo(self.baseView.mas_top).offset(26/2);
    //        make.right.equalTo(self.baseView.mas_right);
    ////        make.height.equalTo(@(30));
    //    }];
    
    [self.titleLeftImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.baseView.mas_left);
        make.centerY.equalTo(self.titleLabel.mas_centerY);
        make.width.equalTo(@(4/2));
        make.height.equalTo(@(20));
    }];
    
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
#pragma mark - 学员端代码处理
        //#ifdef Main
        //        make.left.equalTo(self.titleLeftImg.mas_right).offset(10);
        //#else
        make.left.equalTo(self.titleLeftImg.mas_right).offset(30/2);
        //#endif
        make.top.equalTo(self.baseView.mas_top).offset(26/2);
        make.right.equalTo(self.baseView.mas_right).offset(-30/2);
        //        make.width.equalTo(@(100));
        //        make.height.equalTo(@(30));
    }];
    
    [self.subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
#pragma mark - 学员端代码处理
        //#ifdef Main
        //        make.left.equalTo(self.titleLeftImg.mas_right).offset(10);
        //#else
        make.left.equalTo(self.titleLabel.mas_left);
        //#endif
        make.top.equalTo(self.titleLabel.mas_bottom).offset(24/2);
        make.right.equalTo(self.titleLabel.mas_right);
    }];
    [self.titleRightImg mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(self.baseView.mas_right).offset(-34/2);
        make.centerY.equalTo(self.titleLabel.mas_centerY);
        make.width.equalTo(@(32/2));
        make.height.equalTo(@(32/2));
    }];
    
    [self.Label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel.mas_left);
        make.top.equalTo(self.subTitleLabel.mas_bottom).offset(44/2);
        //#ifdef Main
        if([getUIStyle() isEqualToString:STYLE0]){
            //        make.width.equalTo(@(100));
        }else{
        }
        //    }
        //#endif
        //        make.height.equalTo(@(30));
    }];
    
    [self.Label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.Label1.mas_left);
        make.top.equalTo(self.Label1.mas_bottom).offset(30/2);
        
        
    }];
    
    
    
    _starV =[[UIView alloc]init];
    [self.baseView addSubview:_starV];
    [_starV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.Label2.mas_right).offset(25);
        //#endif
        make.height.equalTo(@(18));
        make.centerY.equalTo(self.Label2.mas_centerY);
        make.right.equalTo(self.baseView.mas_right).offset(-30/2);
    }];
    
    
    UIImageView *im1 =[[UIImageView alloc]init];
    [_starV addSubview:im1];
    [im1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_starV.mas_left);
        make.top.equalTo(_starV.mas_top);
        make.width.equalTo(@(18));
        make.height.equalTo(@(18));
    }];
    im1.tag =1000001;
    
    UIImageView *im2 =[[UIImageView alloc]init];
    [_starV addSubview:im2];
    [im2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(im1.mas_right).offset(6);
        make.top.equalTo(_starV.mas_top);
        make.width.equalTo(@(18));
        make.height.equalTo(@(18));
    }];
    im2.tag =1000002;
    
    UIImageView *im3 =[[UIImageView alloc]init];
    [_starV addSubview:im3];
    [im3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(im2.mas_right).offset(6);
        make.top.equalTo(_starV.mas_top);
        make.width.equalTo(@(18));
        make.height.equalTo(@(18));
    }];
    im3.tag =1000003;
    
    UIImageView *im4 =[[UIImageView alloc]init];
    [_starV addSubview:im4];
    [im4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(im3.mas_right).offset(6);
        make.top.equalTo(_starV.mas_top);
        make.width.equalTo(@(18));
        make.height.equalTo(@(18));
    }];
    im4.tag =1000004;
    
    UIImageView *im5 =[[UIImageView alloc]init];
    [_starV addSubview:im5];
    [im5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(im4.mas_right).offset(6);
        make.top.equalTo(_starV.mas_top);
        make.width.equalTo(@(18));
        make.height.equalTo(@(18));
    }];
    im5.tag =1000005;
    im5.image =[UIImage imageNamed:@"already"];
    im4.image =[UIImage imageNamed:@"already"];
    im3.image =[UIImage imageNamed:@"already"];
    im2.image =[UIImage imageNamed:@"already"];
    im1.image =[UIImage imageNamed:@"already"];
    
    [self.Label3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.Label2.mas_left);
        make.top.equalTo(self.Label2.mas_bottom).offset(30/2);
        
    }];
    
    [self.Label4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.Label3.mas_left);
        make.top.equalTo(self.Label3.mas_bottom).offset(30/2);
        
    }];
    
    [self.Label5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.Label4.mas_left);
        make.top.equalTo(self.Label4.mas_bottom).offset(30/2);
        
    }];
    
    [self.Label1R mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.Label1.mas_right).offset(25);
        
        make.centerY.equalTo(self.Label1.mas_centerY);
        make.right.equalTo(self.baseView.mas_right).offset(-30/2);
        
        
        
    }];
    
    [self.Label2R mas_makeConstraints:^(MASConstraintMaker *make) {
        //#ifdef Main
        //        make.left.equalTo(self.Label2.mas_right).offset(20);
        //        make.right.equalTo(self.titleRightImg.mas_left);
        //#else
        make.left.equalTo(self.Label2.mas_right).offset(25);
        //#endif
        
        make.centerY.equalTo(self.Label2.mas_centerY);
        make.right.equalTo(self.baseView.mas_right).offset(-30/2);
        //        make.height.equalTo(@(30));
    }];
    
    [self.Label3R mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.Label3.mas_right).offset(25);
        
        make.right.equalTo(self.baseView.mas_right).offset(-30/2);
        make.centerY.equalTo(self.Label3.mas_centerY);
        
        //        make.height.equalTo(@(30));
    }];
    
    [self.Label4R mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.Label4.mas_right).offset(25);
        
        make.right.equalTo(self.baseView.mas_right).offset(-30/2);
        make.centerY.equalTo(self.Label4.mas_centerY);
        
        //        make.height.equalTo(@(30));
    }];
    
    [self.Label5R mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.Label5.mas_right).offset(25);
        
        make.right.equalTo(self.baseView.mas_right).offset(-30/2);
        make.centerY.equalTo(self.Label5.mas_centerY);
        
        //        make.height.equalTo(@(30));
    }];
    
    [_imgLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.baseView.mas_centerX);
        make.bottom.equalTo(self.baseView.mas_bottom).offset(-76/2);
        make.left.equalTo(self.baseView.mas_left);
        make.right.equalTo(self.baseView.mas_right);
        make.height.equalTo(@(1));
    }];
    
    [self.mormalBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.baseView.mas_right).offset(-15);
        make.top.equalTo(_titleRightImg.mas_bottom).offset(30/2);
        make.width.equalTo(@(174/2));
        make.height.equalTo(@(52/2));
    }];
    
    //   [ self.mormalBtn setBackgroundColor:[UIColor colorWithRed:95.0/255.0 green:168.0/255.0 blue:252.0/255.0 alpha:1]];
    [self.mormalBtn setBackgroundImage:[UIImage imageNamed:@"related_btn"] forState:UIControlStateNormal];
    
    self.mormalBtn.layer.cornerRadius = 5;
    self.Label1.font = [UIFont systemFontOfSize:28/2];
    self.Label1.textColor = [UIColor colorWithRed:0xa3/255.0 green:0xa3/255.0 blue:0xa3/255.0 alpha:1];
    
    self.Label2.font = [UIFont systemFontOfSize:28/2];
    self.Label2.textColor = [UIColor colorWithRed:0xa3/255.0 green:0xa3/255.0 blue:0xa3/255.0 alpha:1];
    
    self.Label3.font = [UIFont systemFontOfSize:28/2];
    self.Label3.textColor = [UIColor colorWithRed:0xa3/255.0 green:0xa3/255.0 blue:0xa3/255.0 alpha:1];
    
    self.Label4.font = [UIFont systemFontOfSize:28/2];
    self.Label4.textColor = [UIColor colorWithRed:0xa3/255.0 green:0xa3/255.0 blue:0xa3/255.0 alpha:1];
    
    self.Label5.font = [UIFont systemFontOfSize:28/2];
    self.Label5.textColor = [UIColor colorWithRed:0xa3/255.0 green:0xa3/255.0 blue:0xa3/255.0 alpha:1];
    
    self.Label1R.font = [UIFont systemFontOfSize:32/2];
    self.Label1R.textColor = [UIColor colorWithRed:0x5b/255.0 green:0x5b/255.0 blue:0x5b/255.0 alpha:1];
    
    self.Label2R.font = [UIFont systemFontOfSize:32/2];
    self.Label2R.textColor = [UIColor colorWithRed:0x5b/255.0 green:0x5b/255.0 blue:0x5b/255.0 alpha:1];
    
    self.Label3R.font = [UIFont systemFontOfSize:32/2];
    self.Label3R.textColor = [UIColor colorWithRed:0x5b/255.0 green:0x5b/255.0 blue:0x5b/255.0 alpha:1];
    
    self.Label4R.font = [UIFont systemFontOfSize:32/2];
    self.Label4R.textColor = [UIColor colorWithRed:0x5b/255.0 green:0x5b/255.0 blue:0x5b/255.0 alpha:1];
    
    self.Label5R.font = [UIFont systemFontOfSize:32/2];
    self.Label5R.textColor = [UIColor colorWithRed:0x5b/255.0 green:0x5b/255.0 blue:0x5b/255.0 alpha:1];
    
    self.titleLabel.font = [UIFont systemFontOfSize:32/2];
    self.titleLabel.textColor = [UIColor colorWithRed:0x4c/255.0 green:0x4c/255.0 blue:0x4c/255.0 alpha:1];
    
    self.subTitleLabel.font = [UIFont systemFontOfSize:24/2];
    self.subTitleLabel.textColor = [UIColor colorWithRed:0x85/255.0 green:0x85/255.0 blue:0x85/255.0 alpha:1];
    
    //#ifdef Main
    if([getUIStyle() isEqualToString:STYLE0]){
        NSLog(@"主项目程序");
        self.titleRightImg.image = [UIImage imageNamed:@"列表详细_"];
        [self.mormalBtn setImage:[UIImage imageNamed:@"related_btn1"] forState:UIControlStateNormal];
        [self.mormalBtn setImage:[UIImage imageNamed:@"related_btn1"] forState:UIControlStateHighlighted];
        _titleLeftImg.backgroundColor = [UIColor colorWithRed:0x5d/255.0 green:0xa6/255.0 blue:0xff/255.0 alpha:1];
        
    }else{
        //#elif Student
        
        NSLog(@"学员端程序");
        self.titleRightImg.image = [UIImage imageNamed:@"basics_into"];
        self.titleRightImg.hidden = NO;//去掉红色小箭头
        //    [self.mormalBtn setImage:[UIImage imageNamed:@"xiangguan"] forState:UIControlStateNormal];
        //    [self.mormalBtn setImage:[UIImage imageNamed:@"xiangguan_h"] forState:UIControlStateHighlighted];
        [self.mormalBtn setBackgroundColor:[UIColor colorWithHex:0xff9a41]];
        self.mormalBtn.layer.cornerRadius = 5;
        UIImageView *btnImg =[[UIImageView alloc]init];
        [_mormalBtn addSubview:btnImg];
        [btnImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_mormalBtn.mas_left).offset(5);
            make.centerY.equalTo(_mormalBtn.mas_centerY);
            make.width.equalTo(@(15));
            make.height.equalTo(@(13));
        }];
        btnImg.image =[UIImage imageNamed:@"related"];
        
        UILabel *btnTitle =[[UILabel alloc]init];
        [_mormalBtn addSubview:btnTitle];
        [btnTitle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(btnImg.mas_right).offset(4);
            make.centerY.equalTo(_mormalBtn.mas_centerY);
        }];
        btnTitle.text = @"相关信息";
        btnTitle.textColor =[UIColor colorWithHex:0xff8200];
        btnTitle.font =[UIFont systemFontOfSize:14];
        
        
        [self.mormalBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _titleLeftImg.backgroundColor = [UIColor colorWithHex:0xef5152];
    }
    _line1 = [[UIView alloc]init];
    [self.baseView addSubview:_line1];
    [_line1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.baseView.mas_left).offset(KWIDTH/3);
        make.bottom.equalTo(self.baseView.mas_bottom).offset(-10.5);
        make.width.equalTo(@(0.5));
        make.height.equalTo(@(17));
    }];
    _line1.backgroundColor =[UIColor colorWithHex:0xdbdbdb];
    
    
    _line2 = [[UIView alloc]init];
    [self.baseView addSubview:_line2];
    [_line2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_line1.mas_left).offset(KWIDTH/3);
        make.bottom.equalTo(self.baseView.mas_bottom).offset(-10.5);
        make.width.equalTo(@(0.5));
        make.height.equalTo(@(17));
    }];
    _line2.backgroundColor =[UIColor colorWithHex:0xdbdbdb];
    
    
    _imgLine.backgroundColor =[UIColor colorWithHex:0xe7e7e7];
    
    self.bottomBtn1 = [[BottomBtn2 alloc]init];
    [self.BtnView addSubview:_bottomBtn1];
    [_bottomBtn1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.BtnView.mas_left);
        make.bottom.equalTo(self.BtnView.mas_bottom);
        make.width.equalTo(@(KWIDTH/3));
        make.height.equalTo(self.BtnView.mas_height);
    }];
    [_bottomBtn1 addTarget:self action:@selector(btn1Click:) forControlEvents:UIControlEventTouchUpInside];
    
    self.bottomBtn2 = [[BottomBtn2 alloc]init];
    [self.BtnView addSubview:_bottomBtn2];
    [_bottomBtn2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_line1.mas_left);
        make.bottom.equalTo(self.BtnView.mas_bottom);
        make.width.equalTo(@(KWIDTH/3));
        make.height.equalTo(self.BtnView.mas_height);
    }];
    [_bottomBtn2 addTarget:self action:@selector(btn2Click:) forControlEvents:UIControlEventTouchUpInside];
    
    self.bottomBtn3 = [[BottomBtn2 alloc]init];
    [self.BtnView addSubview:_bottomBtn3];
    [_bottomBtn3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_line2.mas_left);
        make.bottom.equalTo(self.BtnView.mas_bottom);
        make.width.equalTo(@(KWIDTH/3));
        make.height.equalTo(self.BtnView.mas_height);
    }];
    [_bottomBtn3 addTarget:self action:@selector(btn3Click:) forControlEvents:UIControlEventTouchUpInside];
    
    if ([getUserType() isEqualToString:UserISHPSStudent]) {
        self.bottomBtn1.btnImg.image =[UIImage imageNamed:@"edit_b"];
        self.bottomBtn1.btnTitle.textColor =[UIColor colorWithHex:0xff8200];
        
        self.bottomBtn2.btnImg.image =[UIImage imageNamed:@"time_b"];
        self.bottomBtn2.btnTitle.textColor =[UIColor colorWithHex:0xff8200];
        
        self.bottomBtn3.btnImg.image =[UIImage imageNamed:@"del_b"];
        self.bottomBtn3.btnTitle.textColor =[UIColor colorWithHex:0xff8200];

    }else{
        self.bottomBtn1.btnImg.image =[UIImage imageNamed:@"edit_a"];
        self.bottomBtn1.btnTitle.textColor =[UIColor colorWithHex:0x5ca6ff];
        
        self.bottomBtn2.btnImg.image =[UIImage imageNamed:@"time_a"];
        self.bottomBtn2.btnTitle.textColor =[UIColor colorWithHex:0x5ca6ff];
        
        self.bottomBtn3.btnImg.image =[UIImage imageNamed:@"del_a"];
        self.bottomBtn3.btnTitle.textColor =[UIColor colorWithHex:0x5ca6ff];

    }

    return self.baseView;
}

-(void)setBtnsArr:(NSArray *)btnsArr{
    _btnsArr = btnsArr;
    if(btnsArr.count==0){
        _bottomBtn3.hidden = YES;
        _bottomBtn2.hidden = YES;
        _bottomBtn1.hidden = YES;
        _line1.hidden = YES;     // 没有按钮的情况下两个竖线都隐藏
        _line2.hidden = YES;     // 没有按钮的情况下两个竖线都隐藏
        _imgLine.hidden = YES;   // 没有按钮的情况下操作按钮上方的横线隐藏
    }else if (btnsArr.count==1){
        _bottomBtn3.hidden = YES;
        _bottomBtn2.hidden = YES;
        _bottomBtn1.hidden = NO;
        _line1.hidden = YES;    // 只有一个按钮的情况下两个竖线都隐藏
        _line2.hidden = YES;    // 只有一个按钮的情况下两个竖线都隐藏
        _imgLine.hidden = NO;   // 没有按钮的情况下操作按钮上方的横线不隐藏
        
        _bottomBtn1.dic = _btnsArr[0];
        

        _bottomBtn1.btnTitle.text = [btnsArr[0] objectForKey:@"buttonName"];
        
        //*** 当 只有 一个按钮时重新布局
        [self masoryUIOneBtn];
        
    }else if (btnsArr.count==2){
        _bottomBtn3.hidden = YES;
        _bottomBtn2.hidden = NO;
        _bottomBtn1.hidden = NO;
        _line1.hidden = NO;     // 有两个按钮的情况下只隐藏一个隐藏
        _line2.hidden = YES;    // 有两个按钮的情况下只隐藏一个隐藏
        _imgLine.hidden = NO;   // 没有按钮的情况下操作按钮上方的横线不隐藏
        
        _bottomBtn1.dic = _btnsArr[0];
        _bottomBtn2.dic = _btnsArr[1];
        

        _bottomBtn1.btnTitle.text = [btnsArr[0] objectForKey:@"buttonName"];
        _bottomBtn2.btnTitle.text = [btnsArr[1] objectForKey:@"buttonName"];
        
        //*** 当 只有 两个按钮时重新布局
        [self masoryUITwoBtn];
    }else{
        _bottomBtn3.hidden = NO;
        _bottomBtn2.hidden = NO;
        _bottomBtn1.hidden = NO;
        _line1.hidden = NO;     // 有三个按钮的情况下
        _line2.hidden = NO;    // 有
        _imgLine.hidden = NO;   // 没有按钮的情况下操作按钮上方的横线不隐藏
        
        _bottomBtn1.dic = _btnsArr[0];
        _bottomBtn2.dic = _btnsArr[1];
        _bottomBtn3.dic = _btnsArr[2];
        
        _bottomBtn1.btnTitle.text = [btnsArr[0] objectForKey:@"buttonName"];
        _bottomBtn2.btnTitle.text = [btnsArr[1] objectForKey:@"buttonName"];
        _bottomBtn3.btnTitle.text = [btnsArr[2] objectForKey:@"buttonName"];
        
        //*** 当 只有 三个按钮时重新布局
        [self masoryUIThreeBtn];

    }
    
    _bottomBtn1.indexPath = self.indexPath;
    _bottomBtn2.indexPath = self.indexPath;
    _bottomBtn3.indexPath = self.indexPath;
    
}

#pragma mark - 当只有一个按钮时只更改 一个按钮的 布局
-(void)masoryUIOneBtn{
    [_bottomBtn1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.baseView.mas_left);
        make.width.equalTo(self.baseView.mas_width);
        make.height.equalTo(self.BtnView.mas_height);
        make.bottom.equalTo(self.BtnView.mas_bottom);
    }];
//    _bottomBtn1.backgroundColor = [UIColor redColor];
}

#pragma mark - 当只有两个按钮时只更改 两个按钮的 布局
-(void)masoryUITwoBtn{
    [_bottomBtn1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.baseView.mas_left);
        //        make.right.equalTo(self.BtnView.mas_right);
        make.width.equalTo(@(KWIDTH/2));
        make.height.equalTo(self.BtnView.mas_height);
        make.bottom.equalTo(self.BtnView.mas_bottom);
    }];
    
    [_bottomBtn2 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bottomBtn1.mas_right);
        make.width.equalTo(@(KWIDTH/2));
        make.height.equalTo(self.BtnView.mas_height);
        make.bottom.equalTo(self.BtnView.mas_bottom);
    }];
    
    
    [_line1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bottomBtn1.mas_right);
        make.bottom.equalTo(self.baseView.mas_bottom).offset(-10.5);
        make.width.equalTo(@(0.5));
        make.height.equalTo(@(17));
    }];
}

#pragma mark - 当只有三个按钮时只更改 三个按钮的 布局
-(void)masoryUIThreeBtn{
    [_bottomBtn1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.baseView.mas_left);
        //        make.right.equalTo(self.BtnView.mas_right);
        make.width.equalTo(@(KWIDTH/3));
        make.height.equalTo(self.BtnView.mas_height);
        make.bottom.equalTo(self.BtnView.mas_bottom);
    }];
    
    [_bottomBtn2 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bottomBtn1.mas_right);
        make.width.equalTo(@(KWIDTH/3));
        make.height.equalTo(self.BtnView.mas_height);
        make.bottom.equalTo(self.BtnView.mas_bottom);
    }];
    
    [_bottomBtn3 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bottomBtn2.mas_right);
        make.width.equalTo(@(KWIDTH/3));
        make.height.equalTo(self.BtnView.mas_height);
        make.bottom.equalTo(self.BtnView.mas_bottom);
    }];
    
    [_line1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bottomBtn1.mas_right);
        make.bottom.equalTo(self.baseView.mas_bottom).offset(-10.5);
        make.width.equalTo(@(0.5));
        make.height.equalTo(@(17));
    }];
    
    [_line2 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bottomBtn2.mas_right);
        make.bottom.equalTo(self.baseView.mas_bottom).offset(-10.5);
        make.width.equalTo(@(0.5));
        make.height.equalTo(@(17));
    }];
}
-(void)btn1Click:(BottomBtn2 *)sender{
    NSLog(@"ddd");
    if ([self.object respondsToSelector:self.quickSelector1]) {
        [self.object performSelector:self.quickSelector1 withObject:sender];
    }
}

-(void)btn2Click:(BottomBtn2 *)btn{
    NSLog(@"ddd");
    if ([self.object respondsToSelector:self.quickSelector2]) {
        [self.object performSelector:self.quickSelector2 withObject:btn];
    }
}

-(void)btn3Click:(BottomBtn2 *)btn{
    NSLog(@"ddd");
    if ([self.object respondsToSelector:self.quickSelector3]) {
        [self.object performSelector:self.quickSelector3 withObject:btn];
    }
}

-(void)prepareForReuse{
    [super prepareForReuse];
    _starNUM = 0;
}

-(void)setCnName:(NSMutableArray *)cnName{
    _cnName = cnName;
    int flagMark = 0;
    for (NSDictionary *dic in _cnName) {
        NSString *str = [dic objectForKey:@"fieldCnName"];
        NSRange range = [str rangeOfString:@"mongodbId"];
        if (range.location != NSNotFound) {
            flagMark ++;
        }
    }
    int maxValue = _cnName.count-flagMark;
    if (_cnName.count>=3&&3<=maxValue){
        _Label1.text = [NSString stringWithFormat:@"%@", [_cnName[2] valueForKey:@"fieldCnName"]];
    }else{
        _Label1.text = @"";
    }
    if (_cnName.count>=4&&4<=maxValue){
        _Label2.text =[NSString stringWithFormat:@"%@",  [_cnName[3] valueForKey:@"fieldCnName"]];
    }else{
        _Label2.text =@"";
    }
    if (_cnName.count>=5&&5<=maxValue){
        _Label3.text =[NSString stringWithFormat:@"%@",  [_cnName[4] valueForKey:@"fieldCnName"]];
    }else{
        _Label3.text =@"";
    }
    if (_cnName.count>=6&&6<=maxValue){
        _Label4.text =[NSString stringWithFormat:@"%@",  [_cnName[5] valueForKey:@"fieldCnName"]];
    }else{
        _Label4.text =@"";
    }if (_cnName.count>=7&&7<=maxValue){
        _Label5.text =[NSString stringWithFormat:@"%@",  [_cnName[6] valueForKey:@"fieldCnName"]];
    }else{
        _Label5.text =@"";
    }
    
    _titleLabel.text = @"";
    _Label1R.text = @"";
    _Label2R.text =@"";
    _Label3R.text =@"";
    _Label4R.text =@"";
    _Label5R.text =@"";
    _Label6R.text =@"";

    
    for (int i = 0; i < _cnName.count; i ++) {
        if (i>=maxValue) {
            break;
        }
        [self  setRightLabel:_dic andSoin:i];
    }
    
//        for (id IDA in _arrqqqqqqqqqq) {
//            NSString *strA = [NSString stringWithFormat:@"%@", IDA];
//    
//            if(_cnName.count>=1){
//                NSString *testStr = [NSString stringWithFormat:@"%@", [_cnName[0] valueForKey:@"fieldAliasName"]] ;
//                NSLog(@"%@",testStr);
//    
//                if ([testStr isEqualToString:strA]) {
//                    _titleLabel.text = [NSString stringWithFormat:@"%@", [_dic valueForKey:strA]];
//    
//    
//                    //                NSString *dicStr =[_dic objectForKey:@"fieldAliasName"];
//                    NSString *lastStr = [NSString stringWithFormat:@"DIC_%@",strA];
//    
//                    //&&![_dic valueForKey:strA]
//                    if([[_dic valueForKey:strA] isKindOfClass:[NSNumber class]]&&![_dic valueForKey:strA]){
//                        _titleLabel.text =[NSString stringWithFormat:@"%@", [_dic objectForKey:lastStr]];
//                    }
//    
//                }
//            }
//            if(_cnName.count>=2){
//                NSString *testStr = [NSString stringWithFormat:@"%@", [_cnName[1] valueForKey:@"fieldAliasName"]] ;
//                NSLog(@"%@",testStr);
//    
//                if ([testStr isEqualToString:strA]) {
//                    _Label1R.text = [NSString stringWithFormat:@"%@", [_dic valueForKey:strA]];
//    
//    
//                    //                NSString *dicStr =[_dic objectForKey:@"fieldAliasName"];
//                    NSString *lastStr = [NSString stringWithFormat:@"DIC_%@",strA];
//    
//                    //&&![_dic valueForKey:strA]
//                    if([[_dic valueForKey:strA] isKindOfClass:[NSNumber class]]&&![_dic valueForKey:strA]){
//                        _Label1R.text =[NSString stringWithFormat:@"%@", [_dic objectForKey:lastStr]];
//                    }
//    
//                }
//            }
//            if(_cnName.count>=3){
//                if ([[NSString stringWithFormat:@"%@", [_cnName[2] valueForKey:@"fieldAliasName"]] isEqualToString:strA]) {
//                    _Label2R.text = [NSString stringWithFormat:@"%@", [_dic valueForKey:strA]];
//    
//                    NSString *ss =[NSString stringWithFormat:@"%@", [_dic valueForKey:strA]];
//                    float aa = [ss floatValue];
//                    int a = (int)(aa+0.5);
//    
//                    self.starNUM = a;
//    
//                    NSString *lastStr = [NSString stringWithFormat:@"DIC_%@",strA];
//    
//                    if([[_dic valueForKey:strA] isKindOfClass:[NSNumber class]]&&![_dic valueForKey:strA]){
//                        _Label2R.text =[NSString stringWithFormat:@"%@", [_dic objectForKey:lastStr]];
//    
//                        NSLog(@"%@", [_dic objectForKey:lastStr]);
//                    }
//    
//                }
//            }
//    
//            if(_cnName.count>=4){
//                if ([[NSString stringWithFormat:@"%@", [_cnName[3] valueForKey:@"fieldAliasName"]] isEqualToString:strA]) {
//                    if (_isNeedDownload) {
//                        NSArray * arr = [[NSString stringWithFormat:@"%@",[_dic valueForKey:strA]] componentsSeparatedByString:@","];
//    
//    
//                        NSLog(@"%@",[_dic valueForKey:strA]);
//                        _Label3R.text = [NSString stringWithFormat:@"%lu个",(unsigned long)arr.count];
//                    }else{
//                        _Label3R.text = [NSString stringWithFormat:@"%@", [_dic valueForKey:strA]];
//    
//                        //                NSString *dicStr =[_dic objectForKey:@"fieldAliasName"];
//                        NSString *lastStr = [NSString stringWithFormat:@"%@",strA];
//                        if([[_dic valueForKey:strA] isKindOfClass:[NSNumber class]]&&![_dic valueForKey:strA]){
//                            _Label3R.text =[NSString stringWithFormat:@"%@", [_dic objectForKey:lastStr]];
//                        }
//                    }
//    
//    
//    
//                }
//            }
//    
//            if(_cnName.count>=5){
//                if ([[NSString stringWithFormat:@"%@", [_cnName[4] valueForKey:@"fieldAliasName"]] isEqualToString:strA]) {
//                    if (_isNeedDownload) {
//                        NSArray * arr = [[NSString stringWithFormat:@"%@",[_dic valueForKey:strA]] componentsSeparatedByString:@","];
//    
//    
//                        NSLog(@"%@",[_dic valueForKey:strA]);
//                        if(arr.count>0){
//                            _Label4R.text =[NSString stringWithFormat:@"%lu个",(unsigned long)arr.count];
//                        }
//                    }else{
//                        _Label4R.text = [NSString stringWithFormat:@"%@", [_dic valueForKey:strA]];
//    
//                        //                NSString *dicStr =[_dic objectForKey:@"fieldAliasName"];
//                        NSString *lastStr = [NSString stringWithFormat:@"%@",strA];
//                        if([[_dic valueForKey:strA] isKindOfClass:[NSNumber class]]&&![_dic valueForKey:strA]){
//                            _Label4R.text =[NSString stringWithFormat:@"%@", [_dic objectForKey:lastStr]];
//                        }
//                    }
//    
//    
//    
//                }
//            }
//    
//        }
//        _image = [_dic objectForKey:@"AFM_1"];
//    NSString * titleStr = [NSString stringWithFormat:@"%@", [_dic objectForKey:_arrqqqqqqqqqq[0]]];
//    
//    
//    _titleLabel.text = titleStr;
//    
//    NSLog(@"%@", _Label2R.text);
    
    
    
}
#pragma mark - 判断附件名称相关字段并返回附件个数
-(NSString *)changeFileNameSameLabelReturnANumber:(NSString *)str andindex:(NSInteger)index{
    NSString *returnStr;
    BOOL ishaveFileName = YES;
//    _cnName
    NSString *cnNameStr = [[_cnName objectAtIndex:index] objectForKey:@"fieldCnName"];
    
    NSRange range = [cnNameStr rangeOfString:@"附件"];
    if (range.location !=NSNotFound) {
        ishaveFileName = YES;
    }else{
        ishaveFileName = NO;
    }
    if (ishaveFileName) {
        if ([str isEqualToString:@""]) {
            return str;
        }
        NSArray * arr = [[NSString stringWithFormat:@"%@",str] componentsSeparatedByString:@","];
        
        
        NSLog(@"%@",str);
        returnStr = [NSString stringWithFormat:@"%lu个",(unsigned long)arr.count];
    }else{
        returnStr = [NSString stringWithFormat:@"%@", str];
        
        //                NSString *dicStr =[_dic objectForKey:@"fieldAliasName"];
//        NSString *lastStr = [NSString stringWithFormat:@"%@",strA];
//        if([[_dic valueForKey:strA] isKindOfClass:[NSNumber class]]&&![_dic valueForKey:strA]){
//            _Label3R.text =[NSString stringWithFormat:@"%@", [_dic objectForKey:lastStr]];
//        }
    }
    return returnStr;
}


#pragma mark - 设置 索引下 右侧 数据
-(void)setRightLabel:(NSDictionary *)dic andSoin:(int)i{
    NSString *strKey = [NSString stringWithFormat:@"cnName_%i", i]; // 将找到的 值 由于 --- 数组 是有序的 所以 存成对应序 所需的 键
    
    switch (i) {
        case 0:
            _titleLabel.text = [self changeFileNameSameLabelReturnANumber:[dic valueForKey:strKey]andindex:i];
            break;
        case 1:
            _subTitleLabel.text = [self changeFileNameSameLabelReturnANumber:[dic valueForKey:strKey]andindex:i];
            break;
        case 2:
            _Label1R.text = [self changeFileNameSameLabelReturnANumber:[dic valueForKey:strKey]andindex:i];
            break;
        case 3:
            _Label2R.text = [self changeFileNameSameLabelReturnANumber:[dic valueForKey:strKey]andindex:i];
            break;
        case 4:
            _Label3R.text = [self changeFileNameSameLabelReturnANumber:[dic valueForKey:strKey]andindex:i];
            break;
        case 5:
            _Label4R.text = [self changeFileNameSameLabelReturnANumber:[dic valueForKey:strKey]andindex:i];
            break;
        case 6:
            _Label5R.text = [self changeFileNameSameLabelReturnANumber:[dic valueForKey:strKey]andindex:i];
            break;
        case 7:
            _Label6R.text = [self changeFileNameSameLabelReturnANumber:[dic valueForKey:strKey]andindex:i];
            break;
        default:
            break;
    }
    
//    if(i == 3){
//        if ([[NSString stringWithFormat:@"%@", [_cnName[2] valueForKey:@"fieldAliasName"]] isEqualToString:strKey]) {
//            _Label2R.text = [NSString stringWithFormat:@"%@", [_dic valueForKey:strKey]];
//            
//            NSString *ss =[NSString stringWithFormat:@"%@", [_dic valueForKey:strKey]];
//            float aa = [ss floatValue];
//            int a = (int)(aa+0.5);
//            
//            self.starNUM = a;
//            
//        }
//        
//    }
//    
//    
//    if(i == 4){
//        if ([[NSString stringWithFormat:@"%@", [_cnName[3] valueForKey:@"fieldAliasName"]] isEqualToString:strKey]) {
//            if (_isNeedDownload) {
//                NSArray * arr = [[NSString stringWithFormat:@"%@",[_dic valueForKey:strKey]] componentsSeparatedByString:@","];
//                
//                
//                NSLog(@"%@",[_dic valueForKey:strKey]);
//                _Label3R.text = [NSString stringWithFormat:@"%lu个",(unsigned long)arr.count];
//            }
//        }
//        
//        
//        
//    }
//    
//    
//    if(i == 5){
//        if ([[NSString stringWithFormat:@"%@", [_cnName[4] valueForKey:@"fieldAliasName"]] isEqualToString:strKey]) {
//            if (_isNeedDownload) {
//                NSArray * arr = [[NSString stringWithFormat:@"%@",[_dic valueForKey:strKey]] componentsSeparatedByString:@","];
//                
//                
//                NSLog(@"%@",[_dic valueForKey:strKey]);
//                if(arr.count>0){
//                    _Label4R.text =[NSString stringWithFormat:@"%lu个",(unsigned long)arr.count];
//                }
//            }
//        }
//        
//        
//    }
    
}

-(void)setStarNUM:(NSInteger)starNUM{
    
    for(int i=0;i<5;i++){
        //                    NSInteger num = [[_dic valueForKey:strA] integerValue];
        NSInteger num = starNUM;
        UIImageView *img =(UIImageView *)[self.contentView viewWithTag:1000000+i+1];
        if(i<num){
            img.image =[UIImage imageNamed:@"already_press"];
        }else{
            img.image =[UIImage imageNamed:@"already"];
        }
    }
    
}


-(void)setDic:(NSDictionary *)dic{
    _dic = dic;
    
    NSArray *arrqqqqq = [dic allKeys]; // 字典 Key 自动排序
    arrqqqqq = [arrqqqqq sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2){
        NSComparisonResult result = [obj1 compare:obj2];
        return result==NSOrderedDescending;
    }];
    _arrqqqqqqqqqq = arrqqqqq;
}
/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end
